// pages/leave-msg-detail/leave-msg-detail.js
var http = require('../../utils/http.js');
var config = require('../../utils/config.js');



Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: 0,
    entity: {},
    list: [],
    news_input_val: ''
  },
  GetDetail() {
    http.request({
      url: "/p/msgSub/list",
      method: "get",
      data: {
        msgId: this.data.entity.msgId,
      },
      callBack: (res) => {
        console.log(res);
        this.setData({
          list: res.records
        });
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let keyName = 'leave-msg-detal-' + options.id;
    let entity = wx.getStorageSync(keyName);
    this.setData({
      entity: entity
    })

    console.log(this.data.entity);
    // wx.removeStorageSync(keyName);

    this.GetDetail();
  },
  bindChange(e) {
    this.setData({
      news_input_val: e.detail.value
    });
  },
  SendMsg() {
   
    http.request({
      url: '/p/msgSub/add',
      method: "post",
      data: {
        msgId: this.data.entity.msgId,
        content: this.data.news_input_val
      },
      callBack: (res) => {
        console.log(res);
        this.setData({
          list: res.records,
          news_input_val:''
        });
        this.GetDetail();
      }
    })

  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})